package com.zhc.dejingapi.utils.common;

import java.util.Calendar;
import java.util.Date;

public class DateTimeUtils {
    public static Date AddYear(Date dInDate,int iAddHour){
        // 使用Calendar对象
        Calendar calendar = Calendar.getInstance();
        calendar.setTime(dInDate);
        calendar.add(Calendar.YEAR, iAddHour); // 减少一小时
        return calendar.getTime();
    }
    public static Date AddMonth(Date dInDate,int iAddHour){
        // 使用Calendar对象
        Calendar calendar = Calendar.getInstance();
        calendar.setTime(dInDate);
        calendar.add(Calendar.MONTH, iAddHour); // 减少一小时
        return calendar.getTime();
    }
    public static Date AddDay(Date dInDate,int iAddHour){
        // 使用Calendar对象
        Calendar calendar = Calendar.getInstance();
        calendar.setTime(dInDate);
        calendar.add(Calendar.DATE, iAddHour); // 减少一小时
        return calendar.getTime();
    }
    public static Date AddHour(Date dInDate,int iAddHour){
        // 使用Calendar对象
        Calendar calendar = Calendar.getInstance();
        calendar.setTime(dInDate);
        calendar.add(Calendar.HOUR, iAddHour); // 减少一小时
        return calendar.getTime();
    }
    public static Date AddMinute(Date dInDate,int iAddHour){
        // 使用Calendar对象
        Calendar calendar = Calendar.getInstance();
        calendar.setTime(dInDate);
        calendar.add(Calendar.MINUTE, iAddHour); // 减少一小时
        return calendar.getTime();
    }
    public static Date AddSecond(Date dInDate,int iAddHour){
        // 使用Calendar对象
        Calendar calendar = Calendar.getInstance();
        calendar.setTime(dInDate);
        calendar.add(Calendar.SECOND, iAddHour); // 减少一小时
        return calendar.getTime();
    }
}
